<?php


namespace suggest_content;


class suggest_needshow
{

    const SN = "SN";
    const AddTime = "AddTime";
    const Account = "AddUserId";
    const AddName = "AddUserName";
    const AddPhone = "AddUserMobile";
    const State = "State";
    const Dept = "AddUserDept";
    const S_Title = "S_Title";
    const S_Type = "S_Type";
    const Type = "Type";
    const ImportantLevel = "ImportantLevel";
    const SuggestDept = "SuggestDept";
    const SuggestImpl = "SuggestImpl";
    const FinishTime = "FinishTime";
    const Score = "Score";
    const PracticalMeasuals = "PracticalMeasuals";
    const CurrentDesc = "CurrentDesc";
    const ImproveMethod = "ImproveMethod";
    const AnticipateResult = "AnticipateResult";
    const RefuseReason = "RefuseReason";
    const CI_EngineerId = "CI_EngineerId";
    const AcceptUserId = "AcceptUserId";
    const refuseName = "refuseName";
    const refuseSegment = "refuseSegment";
    const Notice = "Notice";
    const ForecastTime = "ForecastTime";

    public $suggest_array = array();

    public function make_suggest( array $spar)
    {
        $this->suggest_array[self::SN] = "";
        $this->suggest_array[self::AddTime] = "";
        $this->suggest_array[self::Account] = "";
        $this->suggest_array[self::AddName] = "";
        $this->suggest_array[self::AddPhone] = "";
        $this->suggest_array[self::State] = "";
        $this->suggest_array[self::Dept] = "";
        $this->suggest_array[self::S_Title] = "";
        $this->suggest_array[self::S_Type] = "";
        $this->suggest_array[self::Type] = "";
        $this->suggest_array[self::ImportantLevel] = "";
        $this->suggest_array[self::SuggestDept] = "";
        $this->suggest_array[self::SuggestImpl] = "";
        $this->suggest_array[self::FinishTime] = "";
        $this->suggest_array[self::Score] = "";
        $this->suggest_array[self::PracticalMeasuals] = "";
        $this->suggest_array[self::CurrentDesc] = "";
        $this->suggest_array[self::ImproveMethod] = "";
        $this->suggest_array[self::AnticipateResult] = "";
        $this->suggest_array[self::RefuseReason] = "";
        $this->suggest_array[self::CI_EngineerId] = "";
        $this->suggest_array[self::AcceptUserId] = "";
        $this->suggest_array[self::refuseName] = "";
        $this->suggest_array[self::refuseSegment] = "";
        $this->suggest_array[self::Notice] = "";
        $this->suggest_array[self::ForecastTime] = "";
        foreach ($spar as $key => $value){
            foreach ($this->suggest_array as $key1 => $value1){
                if($key == $key1){
                    $this->suggest_array[$key1] = $value;
                }
            }
            reset($this->suggest_array);
        }
    }

    public function need_show_files($db,$sn){
        echo "<table><tr><th>序号</th><th>icon</th><th>文件名</th><th>大小</th><th>附件环节</th><th>添加时间</th><th>下载</th></tr>";
        $num = 1;
        $from = $db->query("SELECT * from T_SuggestFile WHERE SN = '$sn'");
        while($row = $from->fetch()){
            $fileid = $row['FileId'];
            $from_file = $db->query("SELECT FileName,FilePath,FileSize,FileType,FilePath from Base_FileInfo WHERE FileId='$fileid'");
            $row_file = $from_file->fetch();
            $path = ltrim($row_file['FilePath'],"~");
            echo "<tr><td>".$num."</td>";
            $num++;
            echo "<td><img src='http://119.27.172.172:8068/Content/images/filetype/".$row_file['FileType'].".png' width='20' height='20'></td>";
            echo "<td>".$row_file['FileName']."</td><td>".$row_file['FileSize']."KB</td><td>".$row['Cate']."</td><td>".$row['AddTime']."</td><td><a href='http://119.27.172.172:8068".$path."' download='' target='_blank'>下载附件</a></td></tr>";
        }
        echo "</table>";
    }

    public function from_sql($db,$sn){
        $from = $db->query("SELECT * from T_Suggest WHERE SN = '$sn'");
        $row = $from->fetch();
        $this->make_suggest($row);
        $from = $db->query("SELECT * from T_SuggestReason WHERE SN = '$sn'");
        $row = $from->fetch();
        if($row){
            $this->suggest_array[self::RefuseReason] = $row['RefuseReason'];;
            $this->suggest_array[self::refuseSegment] = $row['AddSegment'];
        }
    }
}
